package com.cn.mobileproject.activity.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cn.mobileproject.data.GlobalValue;
import com.cn.mobileproject.data.SystemParams;
import com.cn.mobileproject.manager.TaskManager;
import com.net.http.HttpException;

@SuppressLint("ValidFragment")
public class HoldTaskFragment extends TaskFragment {

	public HoldTaskFragment(){
		super();
	}
	
	public HoldTaskFragment(boolean check){
		super(check);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		return super.onCreateView(inflater, container, savedInstanceState);
				
	}
	
	protected void initComponent(){
		super.initComponent();
		adapter.setList(GlobalValue.getInstance().getHoldInstructs());
		adapter.notifyDataSetChanged();
		type =2;
	}
	
	protected void initEvent(){
		super.initEvent();
	}
	
	protected boolean isFirstInitData(){
		if(SystemParams.loadHoldInstruct==0) return true;
		return false;
	}
	
	@Override
	public void initInstructData() {
		super.initInstructData();
		if(GlobalValue.getInstance().getHoldInstructs()!=null)GlobalValue.getInstance().getHoldInstructs().clear();
		total = TaskManager.getInstance().initHoldInstruct(GlobalValue.getInstance().getHoldInstructs(),pageNo, PAGESIZE);
		
		if(GlobalValue.getInstance().getHoldInstructs()!=null)start = GlobalValue.getInstance().getHoldInstructs().size();
	}

	@Override
	public void setAdapterList() {
		super.setAdapterList();
		adapter.setList(GlobalValue.getInstance().getHoldInstructs());
		adapter.notifyDataSetChanged();
	}

	@Override
	protected void onSearchSuccess() {
		adapter.setList(GlobalValue.getInstance().getHoldInstructs());
		adapter.notifyDataSetChanged();
		
	}

	@Override
	protected void searchNextPageByCom() throws HttpException {
		pageNo++;
		total = TaskManager.getInstance().initHoldInstruct(GlobalValue.getInstance().getHoldInstructs(),pageNo, PAGESIZE);
		if(GlobalValue.getInstance().getHoldInstructs()!=null)start = GlobalValue.getInstance().getHoldInstructs().size();
	}
	
	public void doJob(){
		if(SystemParams.loadHoldInstruct==0){
			doLoadTask();
		}
		else{
			mRefreshListView.onRefreshComplete();
		}
	}


	
}
